<template>
  <div class="oxford-phd-dashboard min-h-screen p-6" 
       :class="themeState.isLight ? 'bg-gradient-to-br from-gray-50 to-gray-100' : 'system-bg'">
    <!-- Header Section -->
    <div class="glass-card p-8 mb-8">
      <div class="flex items-center justify-between mb-6">
        <div class="flex items-center">
          <div class="w-16 h-16 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-full flex items-center justify-center mr-6">
            <div class="text-2xl">🎓</div>
          </div>
          <div>
            <h1 class="text-3xl font-bold text-white mb-2">葡萄牙博士回国计划</h1>
            <p class="text-blue-200">Dr. João Silva | 环境科学博士 | 牛津大学博士后</p>
            <div class="flex items-center mt-2">
              <MapPin class="w-4 h-4 text-green-400 mr-2" />
              <span class="text-green-400 text-sm">目标城市: 上海 | 最优人才政策匹配: 95%</span>
            </div>
          </div>
        </div>
        <div class="text-right">
          <div class="text-2xl font-bold text-electric-500">¥800万</div>
          <div class="text-white/70 text-sm">预计政策支持总额</div>
        </div>
      </div>

      <!-- Key Statistics -->
      <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
        <div class="bg-white/5 rounded-lg p-4 text-center">
          <div class="text-2xl font-bold text-blue-400 mb-2">28篇</div>
          <div class="text-white/70 text-sm">发表论文</div>
        </div>
        <div class="bg-white/5 rounded-lg p-4 text-center">
          <div class="text-2xl font-bold text-green-400 mb-2">1,580次</div>
          <div class="text-white/70 text-sm">论文引用</div>
        </div>
        <div class="bg-white/5 rounded-lg p-4 text-center">
          <div class="text-2xl font-bold text-purple-400 mb-2">5年</div>
          <div class="text-white/70 text-sm">海外经验</div>
        </div>
        <div class="bg-white/5 rounded-lg p-4 text-center">
          <div class="text-2xl font-bold text-yellow-400 mb-2">95%</div>
          <div class="text-white/70 text-sm">匹配度</div>
        </div>
      </div>
    </div>

    <!-- City Comparison -->
    <div class="glass-card p-8 mb-8">
      <h2 class="text-2xl font-bold text-white mb-6 flex items-center">
        <BarChart3 class="w-8 h-8 mr-3 text-blue-400" />
        各城市人才政策对比分析
      </h2>

      <div class="overflow-x-auto">
        <table class="w-full">
          <thead>
            <tr class="border-b border-white/20">
              <th class="text-left text-white font-semibold py-4">城市</th>
              <th class="text-center text-white font-semibold py-4">住房补贴</th>
              <th class="text-center text-white font-semibold py-4">科研启动</th>
              <th class="text-center text-white font-semibold py-4">税收优惠</th>
              <th class="text-center text-white font-semibold py-4">生活成本</th>
              <th class="text-center text-white font-semibold py-4">推荐指数</th>
            </tr>
          </thead>
          <tbody>
            <tr class="border-b border-white/10 bg-green-500/10">
              <td class="py-4 flex items-center">
                <span class="text-lg mr-2">🏙️</span>
                <span class="text-white font-semibold">上海</span>
                <span class="ml-2 px-2 py-1 bg-green-500/20 text-green-300 rounded text-xs">推荐</span>
              </td>
              <td class="py-4 text-center text-green-400 font-semibold">300万</td>
              <td class="py-4 text-center text-green-400 font-semibold">500万</td>
              <td class="py-4 text-center text-green-400 font-semibold">5年免征</td>
              <td class="py-4 text-center text-yellow-400">较高</td>
              <td class="py-4 text-center">
                <div class="flex justify-center">
                  <Star v-for="n in 5" :key="n" class="w-4 h-4 text-yellow-400 fill-current" />
                </div>
              </td>
            </tr>
            <tr class="border-b border-white/10">
              <td class="py-4 flex items-center">
                <span class="text-lg mr-2">🏛️</span>
                <span class="text-white">北京</span>
              </td>
              <td class="py-4 text-center text-blue-400 font-semibold">200万</td>
              <td class="py-4 text-center text-blue-400 font-semibold">500万</td>
              <td class="py-4 text-center text-blue-400 font-semibold">3年免征</td>
              <td class="py-4 text-center text-yellow-400">较高</td>
              <td class="py-4 text-center">
                <div class="flex justify-center">
                  <Star v-for="n in 4" :key="n" class="w-4 h-4 text-yellow-400 fill-current" />
                  <Star class="w-4 h-4 text-gray-400" />
                </div>
              </td>
            </tr>
            <tr class="border-b border-white/10">
              <td class="py-4 flex items-center">
                <span class="text-lg mr-2">🌸</span>
                <span class="text-white">深圳</span>
              </td>
              <td class="py-4 text-center text-purple-400 font-semibold">300万</td>
              <td class="py-4 text-center text-purple-400 font-semibold">300万</td>
              <td class="py-4 text-center text-purple-400 font-semibold">5年免征</td>
              <td class="py-4 text-center text-green-400">适中</td>
              <td class="py-4 text-center">
                <div class="flex justify-center">
                  <Star v-for="n in 4" :key="n" class="w-4 h-4 text-yellow-400 fill-current" />
                  <Star class="w-4 h-4 text-gray-400" />
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>

    <!-- Shanghai Tax Reporting -->
    <div class="glass-card p-8 mb-8">
      <h2 class="text-2xl font-bold text-white mb-6 flex items-center">
        <DollarSign class="w-8 h-8 mr-3 text-green-400" />
        上海海外资产税务申报流程
      </h2>

      <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
        <!-- Tax Process Flow -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-4">申报流程图</h3>
          <div class="space-y-3">
            <div v-for="(step, index) in taxSteps" :key="index" 
                 :class="[
                   'p-4 rounded-lg border-l-4 transition-all',
                   step.status === 'completed' ? 'bg-green-500/10 border-green-400' :
                   step.status === 'current' ? 'bg-blue-500/10 border-blue-400' : 'bg-gray-500/10 border-gray-400'
                 ]">
              <div class="flex items-center justify-between mb-2">
                <h4 class="text-white font-semibold">{{ step.title }}</h4>
                <span :class="[
                  'px-2 py-1 rounded text-xs font-semibold',
                  step.status === 'completed' ? 'bg-green-500/20 text-green-300' :
                  step.status === 'current' ? 'bg-blue-500/20 text-blue-300' : 'bg-gray-500/20 text-gray-300'
                ]">
                  {{ step.status === 'completed' ? '已完成' :
                     step.status === 'current' ? '进行中' : '待开始' }}
                </span>
              </div>
              <p class="text-white/80 text-sm mb-2">{{ step.description }}</p>
              <div class="flex items-center justify-between text-xs">
                <span class="text-white/70">预计时间: {{ step.duration }}</span>
                <span class="text-white/70">办理地点: {{ step.location }}</span>
              </div>
            </div>
          </div>
        </div>

        <!-- Required Documents -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-4">所需材料清单</h3>
          <div class="space-y-3">
            <div v-for="doc in requiredDocuments" :key="doc.name" 
                 class="p-3 bg-white/5 rounded-lg">
              <div class="flex items-center justify-between mb-2">
                <span class="text-white font-semibold text-sm">{{ doc.name }}</span>
                <div class="flex items-center">
                  <CheckCircle v-if="doc.prepared" class="w-4 h-4 text-green-400 mr-1" />
                  <Clock v-else class="w-4 h-4 text-yellow-400 mr-1" />
                  <span :class="doc.prepared ? 'text-green-400' : 'text-yellow-400'" class="text-xs">
                    {{ doc.prepared ? '已准备' : '准备中' }}
                  </span>
                </div>
              </div>
              <p class="text-white/70 text-xs">{{ doc.description }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 功能操作面板 -->
    <div class="glass-card p-8 mb-8">
      <h2 class="text-2xl font-bold text-white mb-6 flex items-center">
        <BarChart3 class="w-8 h-8 mr-3 text-blue-400" />
        智能求职助手
      </h2>

      <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
        <!-- 政策分析 -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-3">政策分析</h3>
          <div class="space-y-2">
            <button @click="compareCityPolicies" class="w-full px-4 py-3 bg-blue-500/20 text-blue-300 rounded-lg hover:bg-blue-500/30 transition-colors flex items-center">
              <MapPin class="w-4 h-4 mr-2" />
              城市政策对比
            </button>
            <button @click="analyzeBenefits" class="w-full px-4 py-3 bg-indigo-500/20 text-indigo-300 rounded-lg hover:bg-indigo-500/30 transition-colors flex items-center">
              <BarChart3 class="w-4 h-4 mr-2" />
              福利待遇分析
            </button>
            <button @click="predictPolicyTrends" class="w-full px-4 py-3 bg-purple-500/20 text-purple-300 rounded-lg hover:bg-purple-500/30 transition-colors flex items-center">
              <Star class="w-4 h-4 mr-2" />
              政策趋势预测
            </button>
          </div>
        </div>

        <!-- 申请管理 -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-3">申请管理</h3>
          <div class="space-y-2">
            <button @click="materialChecklist" class="w-full px-4 py-3 bg-green-500/20 text-green-300 rounded-lg hover:bg-green-500/30 transition-colors flex items-center">
              <CheckCircle class="w-4 h-4 mr-2" />
              材料准备清单
            </button>
            <button @click="timelinePlanning" class="w-full px-4 py-3 bg-emerald-500/20 text-emerald-300 rounded-lg hover:bg-emerald-500/30 transition-colors flex items-center">
              <Clock class="w-4 h-4 mr-2" />
              申请时间规划
            </button>
            <button @click="progressTracking" class="w-full px-4 py-3 bg-teal-500/20 text-teal-300 rounded-lg hover:bg-teal-500/30 transition-colors flex items-center">
              <Users class="w-4 h-4 mr-2" />
              进度跟踪
            </button>
          </div>
        </div>

        <!-- 税务计算 -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-3">税务计算</h3>
          <div class="space-y-2">
            <button @click="taxCalculator" class="w-full px-4 py-3 bg-yellow-500/20 text-yellow-300 rounded-lg hover:bg-yellow-500/30 transition-colors flex items-center">
              <DollarSign class="w-4 h-4 mr-2" />
              税负计算器
            </button>
            <button @click="generateTaxForm" class="w-full px-4 py-3 bg-orange-500/20 text-orange-300 rounded-lg hover:bg-orange-500/30 transition-colors flex items-center">
              <CheckCircle class="w-4 h-4 mr-2" />
              申报表生成
            </button>
            <button @click="riskAssessment" class="w-full px-4 py-3 bg-red-500/20 text-red-300 rounded-lg hover:bg-red-500/30 transition-colors flex items-center">
              <Clock class="w-4 h-4 mr-2" />
              风险评估
            </button>
          </div>
        </div>

        <!-- 生活规划 -->
        <div class="space-y-4">
          <h3 class="text-white font-semibold mb-3">生活规划</h3>
          <div class="space-y-2">
            <button @click="housingSubsidyQuery" class="w-full px-4 py-3 bg-pink-500/20 text-pink-300 rounded-lg hover:bg-pink-500/30 transition-colors flex items-center">
              <MapPin class="w-4 h-4 mr-2" />
              住房补贴查询
            </button>
            <button @click="researchGrantApplication" class="w-full px-4 py-3 bg-violet-500/20 text-violet-300 rounded-lg hover:bg-violet-500/30 transition-colors flex items-center">
              <Star class="w-4 h-4 mr-2" />
              科研资助申请
            </button>
            <button @click="livingCostAssessment" class="w-full px-4 py-3 bg-cyan-500/20 text-cyan-300 rounded-lg hover:bg-cyan-500/30 transition-colors flex items-center">
              <DollarSign class="w-4 h-4 mr-2" />
              生活成本评估
            </button>
          </div>
        </div>
      </div>

      <!-- 智能推荐 -->
      <div class="mt-8 pt-6 border-t border-white/20">
        <h3 class="text-white font-semibold mb-4">AI智能推荐</h3>
        <div class="flex flex-wrap gap-3">
          <button @click="bestCityRecommendation" class="px-4 py-2 bg-gradient-to-r from-blue-500/20 to-purple-500/20 text-white rounded-lg hover:from-blue-500/30 hover:to-purple-500/30 transition-all">
            <MapPin class="w-4 h-4 mr-2 inline" />
            最适合城市推荐
          </button>
          <button @click="personalizedAdvice" class="px-4 py-2 bg-gradient-to-r from-green-500/20 to-emerald-500/20 text-white rounded-lg hover:from-green-500/30 hover:to-emerald-500/30 transition-all">
            <Star class="w-4 h-4 mr-2 inline" />
            个性化建议
          </button>
          <button @click="timelineAssistant" class="px-4 py-2 bg-gradient-to-r from-yellow-500/20 to-orange-500/20 text-white rounded-lg hover:from-yellow-500/30 hover:to-orange-500/30 transition-all">
            <Clock class="w-4 h-4 mr-2 inline" />
            时间规划助手
          </button>
          <button @click="generateApplicationReport" class="px-4 py-2 bg-gradient-to-r from-purple-500/20 to-pink-500/20 text-white rounded-lg hover:from-purple-500/30 hover:to-pink-500/30 transition-all">
            <CheckCircle class="w-4 h-4 mr-2 inline" />
            生成申请报告
          </button>
        </div>
      </div>
    </div>

    <!-- 通知系统 -->
    <div class="fixed top-4 right-4 z-50 space-y-2">
      <div 
        v-for="notification in notifications" 
        :key="notification.id"
        class="max-w-sm p-4 rounded-lg shadow-lg backdrop-blur-md border transition-all duration-300 transform"
        :class="{
          'bg-blue-500/20 border-blue-500/50 text-blue-300': notification.type === 'info',
          'bg-green-500/20 border-green-500/50 text-green-300': notification.type === 'success',
          'bg-yellow-500/20 border-yellow-500/50 text-yellow-300': notification.type === 'warning',
          'bg-red-500/20 border-red-500/50 text-red-300': notification.type === 'error'
        }"
      >
        <div class="flex items-start justify-between">
          <div class="flex-1">
            <p class="text-sm font-medium">{{ notification.message }}</p>
            <p class="text-xs opacity-75 mt-1">{{ notification.timestamp }}</p>
          </div>
          <button 
            @click="notifications.splice(notifications.indexOf(notification), 1)"
            class="ml-2 text-current opacity-75 hover:opacity-100"
          >
            ×
          </button>
        </div>
      </div>
    </div>

    <!-- Success Cases -->
    <div class="glass-card p-8">
      <h2 class="text-2xl font-bold text-white mb-6 flex items-center">
        <Users class="w-8 h-8 mr-3 text-purple-400" />
        成功案例分析
      </h2>

      <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
        <div v-for="case_study in successCases" :key="case_study.name" 
             class="bg-white/5 rounded-lg p-6">
          <div class="flex items-center mb-4">
            <div class="w-12 h-12 bg-gradient-to-r from-purple-500 to-pink-500 rounded-full flex items-center justify-center mr-4">
              <span class="text-white font-bold">{{ case_study.initial }}</span>
            </div>
            <div>
              <h3 class="text-white font-semibold">{{ case_study.name }}</h3>
              <p class="text-white/70 text-sm">{{ case_study.title }}</p>
            </div>
          </div>
          <div class="space-y-3">
            <div class="flex items-center justify-between">
              <span class="text-white/70 text-sm">选择城市</span>
              <span class="text-white">{{ case_study.city }}</span>
            </div>
            <div class="flex items-center justify-between">
              <span class="text-white/70 text-sm">获得支持</span>
              <span class="text-green-400">{{ case_study.support }}</span>
            </div>
            <div class="flex items-center justify-between">
              <span class="text-white/70 text-sm">当前职位</span>
              <span class="text-white">{{ case_study.current_position }}</span>
            </div>
          </div>
          <div class="mt-4 p-3 bg-blue-500/10 rounded-lg">
            <p class="text-blue-300 text-sm">{{ case_study.advice }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive, ref } from 'vue'
import { themeState } from '../services/themeService.js'
import {
  MapPin,
  BarChart3,
  DollarSign,
  Star,
  CheckCircle,
  Clock,
  Users
} from 'lucide-vue-next'

export default {
  name: 'OxfordPhDDashboard',
  components: {
    MapPin,
    BarChart3,
    DollarSign,
    Star,
    CheckCircle,
    Clock,
    Users
  },
  
  setup() {
    const notifications = ref([])
    
    // 添加通知函数
    const addNotification = (message, type = 'info') => {
      const notification = {
        id: Date.now(),
        message,
        type,
        timestamp: new Date().toLocaleTimeString()
      }
      notifications.value.unshift(notification)
      
      setTimeout(() => {
        const index = notifications.value.findIndex(n => n.id === notification.id)
        if (index > -1) {
          notifications.value.splice(index, 1)
        }
      }, 5000)
    }
    
    // 功能方法实现
    const compareCityPolicies = () => {
      // 跳转到区域对比页面
      window.location.href = '#/region-compare'
      addNotification('正在加载城市政策对比分析...', 'info')
    }
    
    const analyzeBenefits = () => {
      // 跳转到政策分析页面
      window.location.href = '#/policy-analysis?type=benefits'
      addNotification('正在分析各城市福利待遇...', 'info')
    }
    
    const predictPolicyTrends = () => {
      // 跳转到政策模拟页面
      window.location.href = '#/policy-simulation?model=talent_policy'
      addNotification('正在预测人才政策趋势...', 'info')
    }

    // 申请管理功能
    const materialChecklist = () => {
      window.location.href = '#/policy-detail?type=material_checklist'
      addNotification('正在打开材料准备清单...', 'info')
    }

    const timelinePlanning = async () => {
      addNotification('正在制定申请时间规划...', 'info')
      setTimeout(() => {
        alert('申请时间规划制定完成！\n\n建议时间表：\n• 第1个月：学历认证和材料准备\n• 第2-3个月：提交各城市人才计划申请\n• 第4-5个月：面试和考核\n• 第6个月：签约和入职准备\n\n详细计划已发送至您的邮箱')
        addNotification('申请时间规划已制定', 'success')
      }, 2000)
    }

    const progressTracking = () => {
      window.location.href = '#/user-center?tab=applications'
      addNotification('正在打开申请进度跟踪...', 'info')
    }

    // 税务计算功能
    const taxCalculator = async () => {
      addNotification('正在启动税负计算器...', 'info')
      setTimeout(() => {
        const calculation = {
          annualIncome: 1200000,
          taxableIncome: 1200000 - 60000,
          personalDeduction: 60000,
          taxRate: '45%',
          estimatedTax: 513000,
          afterTaxIncome: 687000,
          suggestions: [
            '可考虑申请人才优惠政策',
            '建议合理规划海外资产申报',
            '注意专项附加扣除'
          ]
        }
        alert(`税负计算结果：\n\n年收入：¥${calculation.annualIncome.toLocaleString()}\n应纳税所得额：¥${calculation.taxableIncome.toLocaleString()}\n个人所得税：¥${calculation.estimatedTax.toLocaleString()}\n税后收入：¥${calculation.afterTaxIncome.toLocaleString()}\n\n建议：${calculation.suggestions.join('，')}`)
        addNotification('税负计算完成', 'success')
      }, 2000)
    }

    const generateTaxForm = async () => {
      addNotification('正在生成个人所得税申报表...', 'info')
      setTimeout(() => {
        const taxForm = {
          formType: '个人所得税年度自行申报表',
          taxpayerName: '葡萄牙籍博士',
          taxYear: '2024',
          sections: [
            {
              section: '基本信息',
              fields: ['姓名', '纳税人识别号', '居民身份', '联系方式']
            },
            {
              section: '收入信息',
              fields: ['工资薪金', '海外收入', '其他收入', '专项扣除']
            },
            {
              section: '扣除信息',
              fields: ['基本扣除', '专项附加扣除', '其他扣除']
            },
            {
              section: '税款计算',
              fields: ['应纳税所得额', '适用税率', '速算扣除数', '应纳税额']
            }
          ]
        }
        
        const blob = new Blob([JSON.stringify(taxForm, null, 2)], { type: 'application/json' })
        const url = URL.createObjectURL(blob)
        const a = document.createElement('a')
        a.href = url
        a.download = `个人所得税申报表_${new Date().toLocaleDateString()}.json`
        a.click()
        
        addNotification('个人所得税申报表已生成并下载', 'success')
      }, 2500)
    }

    const riskAssessment = async () => {
      addNotification('正在进行税务风险评估...', 'info')
      setTimeout(() => {
        alert('税务风险评估完成！\n\n评估结果：\n• 整体风险：低\n• 海外资产申报风险：中\n• 双重征税风险：低\n• 政策变更风险：中\n\n建议措施：\n• 完整申报海外资产\n• 关注中葡税收协定\n• 保留相关证明文件\n• 定期咨询税务专家')
        addNotification('税务风险评估完成', 'success')
      }, 2200)
    }

    // 生活规划功能
    const housingSubsidyQuery = async () => {
      addNotification('正在查询住房补贴政策...', 'info')
      setTimeout(() => {
        alert('住房补贴政策查询结果：\n\n上海：\n• 购房补贴最高200万\n• 租房补贴每月8000元\n• 最长5年\n\n北京：\n• 购房补贴最高150万\n• 租房补贴每月6000元\n• 最长3年\n\n深圳：\n• 购房补贴最高300万\n• 租房补贴每月10000元\n• 最长5年\n\n详细政策已发送至您的邮箱')
        addNotification('住房补贴政策查询完成', 'success')
      }, 2000)
    }

    const researchGrantApplication = async () => {
      addNotification('正在查询科研资助申请...', 'info')
      setTimeout(() => {
        alert('科研资助申请指南：\n\n国家级：\n• 国家自然科学基金：20-200万\n• 国家重点研发计划：500-2000万\n• 青年千人计划：100-300万\n\n省市级：\n• 上海市科技人才计划：50-500万\n• 深圳市孔雀计划：100-300万\n• 北京市科技新星：30-100万\n\n申请建议：\n• 优先申请青年人才项目\n• 结合当地重点发展领域\n• 准备详细研究计划书')
        addNotification('科研资助申请指南已获取', 'success')
      }, 2500)
    }

    const livingCostAssessment = async () => {
      addNotification('正在评估生活成本...', 'info')
      setTimeout(() => {
        const livingCosts = {
          cities: [
            {
              city: '上海',
              monthlyRent: '8000-15000',
              monthlyFood: '2000-4000',
              monthlyTransport: '500-800',
              monthlyOthers: '2000-3000',
              monthlyTotal: '12500-22800'
            },
            {
              city: '北京',
              monthlyRent: '6000-12000',
              monthlyFood: '1800-3500',
              monthlyTransport: '400-700',
              monthlyOthers: '1800-2800',
              monthlyTotal: '10000-19000'
            },
            {
              city: '深圳',
              monthlyRent: '7000-14000',
              monthlyFood: '2200-4200',
              monthlyTransport: '600-900',
              monthlyOthers: '2200-3200',
              monthlyTotal: '12000-22300'
            }
          ]
        }
        
        const blob = new Blob([JSON.stringify(livingCosts, null, 2)], { type: 'application/json' })
        const url = URL.createObjectURL(blob)
        const a = document.createElement('a')
        a.href = url
        a.download = `生活成本评估报告_${new Date().toLocaleDateString()}.json`
        a.click()
        
        addNotification('生活成本评估报告已生成并下载', 'success')
      }, 2000)
    }

    // 智能推荐功能
    const bestCityRecommendation = () => {
      window.location.href = '#/region-compare?focus=recommendation'
      addNotification('正在分析最适合城市推荐...', 'info')
    }

    const personalizedAdvice = async () => {
      addNotification('正在生成个性化建议...', 'info')
      setTimeout(() => {
        alert('个性化建议生成完成！\n\n基于您的背景分析：\n• 学历：葡萄牙博士学位\n• 专业：建议优先考虑\n• 语言：葡语优势在某些领域有特色\n\n推荐方案：\n1. 首选上海：国际化程度高，政策支持力度大\n2. 次选深圳：创新环境好，发展机会多\n3. 备选北京：科研资源丰富，学术氛围浓厚\n\n详细分析报告已发送至您的邮箱')
        addNotification('个性化建议已生成', 'success')
      }, 2500)
    }

    const timelineAssistant = async () => {
      addNotification('正在制定个人时间规划...', 'info')
      setTimeout(() => {
        alert('个人时间规划制定完成！\n\n6个月规划：\n月1：学历认证+材料准备\n月2：政策研究+城市选择\n月3：申请提交+语言提升\n月4：面试准备+网络建设\n月5：签约谈判+住房准备\n月6：入职准备+生活安排\n\n关键时间点：\n• 3月：春季人才计划申请\n• 6月：面试高峰期\n• 9月：入职高峰期\n• 12月：年度总结申请')
        addNotification('个人时间规划已制定', 'success')
      }, 2000)
    }

    const generateApplicationReport = async () => {
      addNotification('正在生成申请报告...', 'info')
      setTimeout(() => {
        const applicationReport = {
          reportTitle: '海外博士人才引进申请综合报告',
          reportDate: new Date().toLocaleDateString(),
          applicantProfile: {
            education: '葡萄牙博士学位',
            expertise: '研究领域专业',
            language: '中文、葡语、英语',
            experience: '海外科研经验'
          },
          targetCities: [
            {
              city: '上海',
              matchScore: 95,
              advantages: ['国际化程度高', '政策支持力度大', '科研资源丰富'],
              challenges: ['竞争激烈', '生活成本高']
            },
            {
              city: '深圳',
              matchScore: 88,
              advantages: ['创新环境好', '发展机会多', '年轻活力'],
              challenges: ['学术氛围相对不足', '房价较高']
            },
            {
              city: '北京',
              matchScore: 85,
              advantages: ['科研院所多', '学术氛围浓厚', '发展平台大'],
              challenges: ['户口指标有限', '空气质量']
            }
          ],
          recommendations: [
            '建议优先申请上海市海外人才计划',
            '可同时申请多个城市以增加成功率',
            '重点准备学历认证和语言证明',
            '建立学术网络关系'
          ],
          timeline: {
            phase1: '准备阶段（1-2个月）',
            phase2: '申请阶段（2-3个月）',
            phase3: '面试阶段（1个月）',
            phase4: '签约入职（1个月）'
          }
        }
        
        const blob = new Blob([JSON.stringify(applicationReport, null, 2)], { type: 'application/json' })
        const url = URL.createObjectURL(blob)
        const a = document.createElement('a')
        a.href = url
        a.download = `海外博士人才引进申请报告_${new Date().toLocaleDateString()}.json`
        a.click()
        
        addNotification('申请报告已生成并下载', 'success')
      }, 3000)
    }
    const taxSteps = reactive([
      {
        title: '税务登记',
        description: '在上海税务局办理海外人员税务登记，获得中国税号',
        duration: '3-5工作日',
        location: '上海市税务局',
        status: 'completed'
      },
      {
        title: '资产申报',
        description: '提交海外金融资产申报表，包括银行账户、投资组合等',
        duration: '5-7工作日',
        location: '网上税务局',
        status: 'current'
      },
      {
        title: '税务核定',
        description: '税务机关审核资产信息，核定应纳税额',
        duration: '10-15工作日',
        location: '税务局审核',
        status: 'pending'
      },
      {
        title: '缴税确认',
        description: '完成税款缴纳，获得完税证明',
        duration: '1-2工作日',
        location: '银行或网上',
        status: 'pending'
      }
    ])

    const requiredDocuments = reactive([
      {
        name: '护照及签证',
        description: '有效护照原件及工作签证',
        prepared: true
      },
      {
        name: '学历认证',
        description: '教育部留学服务中心学历认证',
        prepared: true
      },
      {
        name: '海外银行流水',
        description: '最近12个月银行账户流水单',
        prepared: false
      },
      {
        name: '投资证明',
        description: '海外投资组合及收益证明',
        prepared: false
      },
      {
        name: '收入证明',
        description: '海外工作收入及税务记录',
        prepared: true
      }
    ])

    const successCases = reactive([
      {
        name: '李博士',
        initial: '李',
        title: '剑桥大学材料学博士',
        city: '上海',
        support: '¥650万',
        current_position: '复旦大学教授',
        advice: '建议重点关注上海的"海聚英才"计划，科研启动资金充足，税收优惠力度大。'
      },
      {
        name: '王博士',
        initial: '王',
        title: 'MIT计算机博士',
        city: '深圳',
        support: '¥500万',
        current_position: '腾讯首席科学家',
        advice: '深圳孔雀计划对科技人才支持力度大，与产业结合紧密，适合技术转化。'
      },
      {
        name: '陈博士',
        initial: '陈',
        title: '哈佛大学生物学博士',
        city: '北京',
        support: '¥580万',
        current_position: '中科院研究员',
        advice: '北京科研院所多，学术氛围浓厚，但要提前关注户口指标和房价成本。'
      }
    ])
    
    // 初始化欢迎消息
    setTimeout(() => {
      addNotification('欢迎使用海外博士人才智能求职助手', 'success')
    }, 1000)
    
    return {
      themeState,
      taxSteps,
      requiredDocuments,
      successCases,
      notifications,
      
      // 政策分析
      compareCityPolicies,
      analyzeBenefits,
      predictPolicyTrends,
      
      // 申请管理
      materialChecklist,
      timelinePlanning,
      progressTracking,
      
      // 税务计算
      taxCalculator,
      generateTaxForm,
      riskAssessment,
      
      // 生活规划
      housingSubsidyQuery,
      researchGrantApplication,
      livingCostAssessment,
      
      // 智能推荐
      bestCityRecommendation,
      personalizedAdvice,
      timelineAssistant,
      generateApplicationReport,
      
      addNotification
    }
  }
}
</script>

<style scoped>
.glass-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.text-electric-500 {
  color: #60a5fa;
}
</style> 